<div class="bjui-pageHeader">
	<div class="glyphicon glyphicon-th-large">还原管理</div>
</div>
<div class="bjui-pageContent">

		<table class="table table-bordered table-hover table-striped table-top">
			<thead>
				<tr>
					<th>备份名称</th>
					<th>卷数</th>
					<th>压缩</th>
					<th>数据大小</th>
					<th>备份时间</th>
					<th>状态</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name='list' item='data'>
					<tr>
						<td>{$data.time|date='Ymd-His',###}</td>
						<td>{$data.part}</td>
						<td>{$data.compress}</td>
						<td>{$data.size|format_bytes}</td>
						<td>{$key}</td>
						<td>-</td>
						<td class="action">
							<a class="db-import" href="{:U('import?time='.$data['time'])}">还原</a>&nbsp;
							<a class="ajax-get confirm" href="{:U('del?time='.$data['time'])}" data-toggle="doajax" data-type="get">删除</a>
						</td>
					</tr>
				</foreach>
			</tbody>
		</table>


	<script type="text/javascript">
		$(".db-import").click(function() {
			var self = this,
				status = ".";
			$.get(self.href, success, "json");
			window.onbeforeunload = function() {
				return "正在还原数据库，请不要关闭！"
			}
			return false;

			function success(data) {
				if (data.status) {
					if (data.gz) {
						data.info += status;
						if (status.length === 5) {
							status = ".";
						} else {
							status += ".";
						}
					}
					$(self).parent().prev().text(data.info);
					if (data.part) {
						$.get(self.href, {
								"part": data.part,
								"start": data.start
							},
							success,
							"json"
						);
					} else {
						window.onbeforeunload = function() {
							return null;
						}
					}
				} else {
					$('#form_do').alertmsg('error', data.info);
				}
			}
		});
	</script>

</div>
<div class="bjui-pageFooter">
	<ul>
		<li>
			<button type="button" class="btn-close" data-icon="close">关闭</button>
		</li>
	</ul>
</div>